From: NIIBE Yutaka Date: Tue, 21 May 2019 06:50:28 +0000 (+0900) Subject: agent: For SSH key, don't put NUL-byte at the end. X-Git-Tag: archive/raspbian/2.2.12-1+rpi1+deb10u1^2~30 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=74397ce95ba4a5a16e38439d2bfc52e6f3046712;p=gnupg2.git agent: For SSH key, don't put NUL-byte at the end. * agent/command-ssh.c (ssh_key_to_protected_buffer): Update the length by the second call of gcry_sexp_sprint. -- GnuPG-bug-id: 4502 Signed-off-by: NIIBE Yutaka (cherry picked from commit 6e39541f4f488fe59eac399bad18c465f373a784) Gbp-Pq: Topic from-2.2.16 Gbp-Pq: Name agent-For-SSH-key-don-t-put-NUL-byte-at-the-end.patch --- diff --git a/agent/command-ssh.c b/agent/command-ssh.c index 9255830..ce621f7 100644 --- a/agent/command-ssh.c +++ b/agent/command-ssh.c @@ -3033,8 +3033,8 @@ ssh_key_to_protected_buffer (gcry_sexp_t key, const char *passphrase, goto out; } - gcry_sexp_sprint (key, GCRYSEXP_FMT_CANON, buffer_new, buffer_new_n); - /* FIXME: guarantee? */ + buffer_new_n = gcry_sexp_sprint (key, GCRYSEXP_FMT_CANON, + buffer_new, buffer_new_n); if (*passphrase) err = agent_protect (buffer_new, passphrase, buffer, buffer_n, 0, -1);